package com.my.study;

import java.util.*;

public class Main {

    public static void main(String[] args) {


        Map<Integer, List<Long>> orderRequireSkuMap = new HashMap<>();
        orderRequireSkuMap.put(1, Arrays.asList(123L, 124L,125L));
        orderRequireSkuMap.put(2, Arrays.asList(123L));

        Map<Integer, List<Long>> docSkuIdMap = new HashMap<>();
        docSkuIdMap.put(1, Arrays.asList(123L, 124L, 123456L));
        docSkuIdMap.put(2, Arrays.asList(123L));

        /*if (orderRequireSkuMap.equals(docSkuIdMap)) {
            // 完全匹配
            System.out.println("完全匹配-=========");
            return;
        }*/

        int include = 0;
        for(Map.Entry<Integer, List<Long>> entry : orderRequireSkuMap.entrySet()){
            if(docSkuIdMap.containsKey(entry.getKey())){
                if(!docSkuIdMap.get(entry.getKey()).containsAll(entry.getValue())){
                    //部分匹配
                    System.out.println("部分匹配=======");
                    return;
                }else{
                    //System.out.println("baohan-==-====");
                    include ++;
                }
            }
        }
        if(include == orderRequireSkuMap.size()){
            System.out.println("======完全匹配-==========");
            return;
        }
        System.out.println("完全不匹配--==========");


        //System.out.println(test());

//        String a = "idx_author_id_sub_channel_id";
//        String b = "index_author_id_sub_channel_id ";
//        System.out.println(a.getBytes().length);
//        System.out.println(b.getBytes().length);
        /*System.out.println(calculate("aabcc","dbbca","aadbbcbcac"));
        System.out.println(isInterleave("aabcc","dbbca","aadbbcbcac"));*/
        /*int [] price = {2,5,3,9,15,2};
        System.out.println(calculateMax(price));*/

        /*Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            int n = scanner.nextInt();
            int [] prices = new int[n];
            for(int i =0;i < n;i++){
                prices[i] = scanner.nextInt();
            }











            System.out.println(calculateMax(prices));
        }*/

    }

    public  static int test(){
        int i = 0;
        int a = 1000000;
        while(i < 5){

            try{
                int j = 100000000;
                a = a / 0;
                if(a != 0){
                    return a;
                }
                i++;
            }catch (Exception e){
                e.printStackTrace();
            }finally {
                i++;
            }
        }
        return a;
    }

    public static boolean isInterleave(String s1, String s2, String s3) {
        // write your code here
        if(s3.length()!=s1.length()+s2.length())
            return false;
        if(s1.length()==0)
            return s2==s3;
        if(s2.length()==0)
            return s1==s3;

        boolean [][] dp = new boolean[s1.length() + 1][s2.length()+ 1];
        dp[0][0] = true;
        for(int i=1;i<=s1.length();i++)
            dp[i][0] = dp[i-1][0]&&(s3.charAt(i-1) ==s1.charAt(i-1));
        for(int i=1;i<=s2.length();i++)
            dp[0][i] = dp[0][i-1]&&(s3.charAt(i-1) ==s2.charAt(i-1));
        for(int i=1;i<=s1.length();i++)
        {
            for(int j=1;j<=s2.length();j++)
            {
                int t = i+j;
                if(s1.charAt(i-1) ==s3.charAt(t-1))
                    dp[i][j] = dp[i][j]||dp[i-1][j];
                if(s2.charAt(j-1) == s3.charAt(t-1))
                    dp[i][j] = dp[i][j]||dp[i][j-1];
            }
        }
        return dp[s1.length()][s2.length()];

    }

    public static boolean isInterleave2(String s1, String s2, String s3) {
        int len1 = (s1 == null) ? 0 : s1.length();
        int len2 = (s2 == null) ? 0 : s2.length();
        int len3 = (s3 == null) ? 0 : s3.length();

        if (len3 != len1 + len2) return false;

        int i1 = 0, i2 = 0;
        for (int i3 = 0; i3 < len3; i3++) {
            boolean result = false;
            if (i1 < len1 && s1.charAt(i1) == s3.charAt(i3)) {
                i1++;
                result = true;
                continue;
            }
            if (i2 < len2 && s2.charAt(i2) == s3.charAt(i3)) {
                i2++;
                result = true;
                continue;
            }

            // return instantly if both s1 and s2 can not pair with s3
            if (!result) return false;
        }

        return true;
    }

    public static boolean calculate(String str1, String str2, String str3){

        if(str3.length() != (str1.length() + str2.length())){
            return false;
        }

        int startStr1 = 0, startStr2 = 0;
        for(int i =0;i < str3.length();i++){

            char tmp3 = str3.charAt(i);
            char tmp1 = ' ';
            if(startStr1 < str1.length()){
                tmp1 = str1.charAt(startStr1);
            }
            char tmp2 = ' ';
            if(startStr2 < str2.length()){
                tmp2 = str2.charAt(startStr2);
            }

            if(tmp3 == tmp1){
                startStr1 ++;
            }else if(tmp3 == tmp2){
                startStr2 ++;
            }else{
                System.out.println("tmp3: " + tmp3 + "   tmp1: " + tmp1 + "   tmp2:" + tmp2);
                return false;
            }
        }
        return true;
    }

    public static int getmax(int [] prices ,int start ,int end )
    {
        int max = 0;
        int min = prices[start];
        for(int i=start+1;i<=end;i++)
        {
            if (prices[i]-min>max)
                max = prices[i]-min;
            if (prices[i]<min)
                min = prices[i];
        }
        return max ;
    }
    /**
     * 计算你能获得的最大收益
     *
     * @param prices Prices[i]即第i天的股价
     * @return 整型
     */
    public static int calculateMax(int[] prices) {
        int sum = 0;

        for (int i = 1; i < prices.length; i++) {
            int temp = getmax(prices, 0, i) + getmax(prices, i, prices.length - 1);
            if (temp > sum)
                sum = temp;
        }
        return sum;
    }
}
